<?php

namespace app\api\controller;

use app\activity\logic\activityLogic;
use app\api\annotation\LoginRequired;
use plugin\saiadmin\basic\OpenController;
use app\policyMatching\logic\PolicyMatchingLogic;
use app\api\basic\BaseController;
use support\Request;
//定时器工具类
class ToolController extends OpenController {
     protected $userInfo;

    /**
     * 当前登陆管理员ID
     */
    protected $userId;

    /**
     * 当前登陆管理员账号
     */
    protected $userName;
    public function __construct()
    {   
        parent::__construct();
        $this->userId=request()->userId;
        $this->userName=request()->userName;
        $this->userInfo=request()->userInfo;
    }
    #[LoginRequired(required: false)]
     public function updatePolicyMatching(Request $request){
        $PolicyMatchingLogic = new PolicyMatchingLogic();
        $PolicyMatchingLogic
        ->where('application_start_time','<=',date('Y-m-d H:i:s'))
        ->where('application_end_time','>=',date('Y-m-d H:i:s'))
        ->update(['status'=>0]);
        $PolicyMatchingLogic
        ->where('application_end_time','<',date('Y-m-d H:i:s'))
        ->update(['status'=>2]);
        return $this->success('操作成功');
    }
    #[LoginRequired(required: false)]
    public function updateActivity(Request $request){
        $activityLogic = new activityLogic();
        $activityLogic
        ->where('activity_start_time','<=',date('Y-m-d H:i:s'))
        ->where('activity_end_time','>=',date('Y-m-d H:i:s'))
        ->update(['status'=>0]);
        $activityLogic
        ->where('activity_end_time','<',date('Y-m-d H:i:s'))
        ->update(['status'=>2]);
        return $this->success('操作成功');
    }
}